import Cookie from 'js-cookie'
export default {
  state:{
    token:''
  },
  mutations: {
    setToken(state,val){
      state.token = val
      Cookie.set('token',val)
    },
    clearToken(state){
      state.token = ''
      Cookie.remove('token')
    },
    getToken(state){
      //如果当前缓存有token就赋给state 如果没有就从state中获取
      state.token = state.token || Cookie.get('token')
    }
  }
}

//我们什么时候去校验token是否存在 --> 路由跳转时导航守卫